#!/bin/bash
ip=$(ifconfig eth0|sed -n '2p'|awk -F "[ :]+" '{print $4}')
user=rsync_backup
BackserverIP=10.100.100.104
Dst=backup
Src=/backup/
[ ! -d /backup/$ip ] && mkdir -p /backup/$ip
cd /backup/$ip &&  tar zcf bak_$(date +%F).tar.gz /var/www/html/ /app/logs/access_$(date +%F -d '-1day').log  /server/scripts /var/spool/cron /etc/rc.local /etc/sysconfig/iptables

#rsync backup file to backup server
rsync -az  $Src $user@$BackserverIP::$Dst --password-file=/etc/rsyncd.passwd && touch ${ip}_flag_$(date +%F)
#删除7天

find $Src -type f -name "*.tar.gz" -mtime +7|xargs rm -f


#
